using System;
using System.Collections.Generic;
using System.Text;

namespace MeetFuture.MRC
{
	public partial class clsPortInfo
	{
        private const string key_PortID = "PORTID=";
        private const string key_Lot = "LOTID=";
        private const string key_Status = "PORTSTATUS=";
        private const string key_split = ",";

        private string _ID = string.Empty;
        private string _LotID = string.Empty;
        private string _Status = string.Empty;
        private bool _IsIdle = false;
        private bool _IsError = false;

        public enum EAP_Port_Status
        {
            Port_Empty = 1,
            Port_Locking = 2,
            Port_Locked = 4,
            Port_Loading = 8,
            Port_Loaded = 16,
            Port_UnLoading = 32,
            Port_UnLoaded = 64,
            Port_UnLocking = 128,
            Port_UnLocked = 256,
            Port_TagUpdating = 512,
            Port_TagUpdated = 1024,
            Port_Full = 2048,
            Port_TagUpdatedFailed = 4096
        }

        public clsPortInfo(string PortID)
        {
            this._ID = PortID;
            this._LotID = string.Empty;
            this._IsIdle = false;
            this._IsError = false;
        }
        public string PortID
        {
            get { return this._ID; }
        }
        public string LotID
        {
            set { this._LotID = value; }
            get { return this._LotID; }
        }
        public string Status
        {
            get { return this._Status; }
            set 
            { 
                this._Status = value.ToUpper();
                switch (this._Status)
                {
                    case "U":
                    case "IDLE":
                    case "PORT_EMPTY":
                    {
                        this._IsError = false;
                        this._IsIdle = true;
                        break;
                    }
                    case "R":
                    {
                        this._IsError = false;
                        this._IsIdle = false;
                        break;
                    }
                	default :
                	{
                        this._IsError = true;
                        this._IsIdle = false;
                		break;
                	}
                }
            }
        }
        public void Set_EAP_Status(EAP_Port_Status status)
        {
            try
            {
                Status = status.ToString();            	
            }
            catch (System.Exception ex)
            {	
            }
        }
        public bool IsIdle
        {
            get { return this._IsIdle; }
        }
        public bool IsError
        {
            get { return this._IsError; }
        }
        public string ToObjectString()
        {
            string result = string.Empty;
            try
            {
                result += "[";
                result += key_PortID + this._ID + key_split;
                result += key_Lot + this._LotID + key_split;
                result += key_Status + ApplicationGlobal.GetPortStatusCode(this._Status) + key_split;
                result += "]";
            }
            catch (System.Exception ex)
            {
            }
            return result;
        }
	}
}
